﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;
using CCWin;
using System.Threading;
using System.IO.Ports;
using System.IO;

namespace weiqijiance.国标自检类
{
    public partial class GBBJZ : CCSkinMain
    {

        public mainform m_mainform;
        public float m_fspeed;
        public float fForce;
        public float fpower;

        public string sASMJGXZ;//是否进行结果修正
        public int iASMtdz;//ASM信号左通道
        public int iASMtdy;//ASM信号右通道
        public int iASMtdh;//ASM信号右通道
        public int iASMHWQ;//ASM到位红外

        public int iASMKZJSS;//ASM举升升
        public int iASMKZJSJ;//ASM举升降
        public int iASMSDtd;//车速信号接在那个通道
        Thread t1;
        Thread t2;

        public List<float> listfSpeedStart = new List<float>();
        public List<float> listfSpeedEnd = new List<float>();
        public List<float> listfpower = new List<float>();

        List<DateTime> listdstart = new List<DateTime>();
        List<DateTime> listdend = new List<DateTime>();

        double[] dtimex = new double[10000];
        double[] dSP = new double[10000];
        double[] dPW = new double[10000];
        double[] dFC = new double[10000];
        DateTime dstartgcsj = new DateTime();
        int igcsj = 0;
        public GBBJZ()
        {
            InitializeComponent();
        }
        #region 控件大小随窗体大小等比例缩放
        private float x;//定义当前窗体的宽度
        private float y;//定义当前窗体的高度
        private void setTag(Control cons)
        {
            foreach (Control con in cons.Controls)
            {
                con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
                if (con.Controls.Count > 0)
                {
                    setTag(con);
                }
            }
        }
        private void setControls(float newx, float newy, Control cons)
        {
            //遍历窗体中的控件，重新设置控件的值
            foreach (Control con in cons.Controls)
            {
                //获取控件的Tag属性值，并分割后存储字符串数组
                if (con.Tag != null)
                {
                    string[] mytag = con.Tag.ToString().Split(new char[] { ';' });
                    //根据窗体缩放的比例确定控件的值
                    con.Width = Convert.ToInt32(System.Convert.ToSingle(mytag[0]) * newx);//宽度
                    con.Height = Convert.ToInt32(System.Convert.ToSingle(mytag[1]) * newy);//高度
                    con.Left = Convert.ToInt32(System.Convert.ToSingle(mytag[2]) * newx);//左边距
                    con.Top = Convert.ToInt32(System.Convert.ToSingle(mytag[3]) * newy);//顶边距
                    Single currentSize = System.Convert.ToSingle(mytag[4]) * newy;//字体大小
                    con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
                    if (con.Controls.Count > 0)
                    {
                        setControls(newx, newy, con);
                    }
                }
            }
        }
        #endregion
        double DIW = 0;
        bool bPutVolstart = false;

        private void GBBJZ_Resize(object sender, EventArgs e)
        {
            float newx = (this.Width) / x;
            float newy = (this.Height) / y;
            setControls(newx, newy, this);
        }
        private void GBBJZ_Load(object sender, EventArgs e)
        {
            //textBox3.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            textBox1.Text = m_mainform.stationCode;
            textBox2.Text = m_mainform.lineCode;
            textBox3.Text = DateTime.Now.ToString("yyyy-MM-dd");
            ///读取检定数据
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\检测设备信息设置.ini";
            string path1 = string.Format(@"{0}", path);
            iniclass objini = new iniclass();
            objini.Ini(path1);

            double.TryParse(objini.ReadValue("检测设备信息", "台架惯量"), out DIW);
            if (DIW < 1)
            {
                DIW = 900;
            }

            double[] fsudus = new double[] { 80.5, 78.8, 77.2, 75.6, 74, 72.4, 70.8, 69.2, 67.6, 66, 64.4, 62.8, 61.1, 59.5, 57.9, 56.3, 54.7, 53.1, 51.5, 49.9, 48.3, 46.7, 45.1, 43.4, 41.8, 40.2, 38.6, 37, 35.4, 33.8, 32.2, 30.6, 29, 27.4, 25.7, 24.1, 22.5, 20.9, 19.3, 17.7, 16.1, 14.5, 12.9, 11.3, 9.7, 8 };
            double[] fgl = new double[] { 3.7, 4.4, 5.1, 5.9, 6.6, 7.4, 5.9, 7.4, 8.8, 10.3, 11.8, 13.2, 14.7, 15.4, 16.2, 16.9, 17.6, 18.4, 17.6, 16.9, 16.2, 15.4, 14.7, 13.2, 11.8, 10.3, 11, 11.8, 12.5, 13.2, 12.5, 11.8, 11, 10.3, 8.8, 7.4, 8.1, 8.8, 8.1, 7.4, 6.6, 5.9, 5.1, 4.4, 3.7, 3.7 };
            for (int i = 0; i < fsudus.Length - 1; i++)
            {
                listdstart.Add(DateTime.Now);
                listdend.Add(DateTime.Now);
                listfSpeedStart.Add((float)fsudus[i]);
                listfSpeedEnd.Add((float)fsudus[i + 1]);
                listfpower.Add((float)fgl[i]);
            }

            x = this.Width;
            y = this.Height;
            setTag(this);
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
        }

        public void gettongdao()
        {

            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\串口及通道设置.ini";
            string path1 = string.Format(@"{0}", path);
            iniclass objini = new iniclass();
            objini.Ini(path1);

            ///读取检定数据

            for (int i = 0; i < 10; i++)
            {
                string sgetname = objini.ReadValue("通道设置", string.Format(@"模拟信号{0}", i + 1));
                if (sgetname.Contains("测功力左"))
                {
                    iASMtdz = i;
                }

                if (sgetname.Contains("测功力右"))
                {
                    iASMtdy = i;
                }

                if (sgetname.Contains("测功力后"))
                {
                    iASMtdh = i;
                }
            }

            for (int i = 0; i < 8; i++)
            {
                string smaichong = objini.ReadValue("通道设置", string.Format(@"速度{0}", i + 1));
                if (smaichong.Contains("速度"))
                {
                    iASMSDtd = i;
                }

            }

            ///控制
            for (int i = 0; i < 8; i++)
            {

                string shongwai = objini.ReadValue("通道设置", string.Format(@"控制{0}", i + 1));
                if (shongwai.Contains("测功举升升"))
                {
                    iASMKZJSS = i;
                }
                if (shongwai.Contains("测功举升降"))
                {
                    iASMKZJSJ = i;
                }
            }
        }
        private void but_kaishi_Click(object sender, EventArgs e)
        {
            bPutVolstart = false;
            gettongdao();
            m_mainform.DAC.tiaoling(1);//调零
             m_mainform.DAC.Lift(false);
            Thread.Sleep(1500);


            m_mainform.DAC.PutVol(0);
            Thread.Sleep(1000);
            m_mainform.BianPinQi(true);
            Thread.Sleep(3000);
            m_mainform.BianPinQiSpeed(256 * 40);//设置频率
            t1 = new Thread(new ThreadStart(Thread1));
            t1.Priority = ThreadPriority.BelowNormal;
            t1.Start();

            t2 = new Thread(new ThreadStart(Thread2));
            t2.Priority = ThreadPriority.BelowNormal;
            t2.Start();

        }

        public void Thread1()
        {
            try
            {
                getstart(88.5);
                Thread.Sleep(1000);
                float fmz = 0;
                float izzmz = 0;
                for (int i = 0; i < listfSpeedEnd.Count; i++)
                {
                    ctrlshuchu(listfSpeedStart[i], listfSpeedEnd[i], listfpower[i], ref fmz, ref izzmz);
                }
                m_mainform.DAC.PutVol(0);//
            }
            catch
            {

            }
        }
        public void getstart(double fspeed)//到达开始检测的速度
        {
            try
            {
                DateTime dpinlv = DateTime.Now;
                dstartgcsj = DateTime.Now;
                while (true)
                {
                    Thread.Sleep(20);
                    //m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                    //float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                    //float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                    //float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                    //fForce = fzou + fyou + fhou;
                    //if (fForce < 0)
                    //{
                    //    fForce = 0;
                    //}

                    if (m_fspeed > fspeed)
                    {
                        m_mainform.BianPinQi(false); ;//关闭电源电源
                        bPutVolstart = true;
                        break;
                    }
                    float fgonglv = (fForce * m_fspeed) / 360;
                }
            }
            catch
            {
                m_mainform.BianPinQi(false); ;//关闭电源电源
            }
        }
        public void ctrlshuchu(double fspeedstart, double fspeedend, double fpowerex, ref float fmz, ref float izzmz)
        {
            try
            {
                float m_fspeedlast = m_fspeed;
                {
                    float forcedq, forcejs;
                    forcedq = fForce;
                    forcejs = m_mainform.DAC.getcyz("涡流输出", fmz);
                    float fblz = 0;
                    fblz = getbljj(forcedq, forcejs);
                    //float fgonglvjs = 0;
                    izzmz += fblz;
                    float fjsd = (m_fspeedlast - m_fspeed) / 300f;
                    float fspeednext = m_fspeed - (fjsd * 300f);
                    float fforcenext = (float)fpowerex * 360f / fspeednext;//不算内阻
                    float fwoliu =  m_mainform.DAC.getwoliu("涡流输出", fforcenext);
                    fmz = fwoliu;
                    fwoliu = fwoliu + izzmz;
                    m_mainform.DAC.PutVol(fwoliu);//
                    m_fspeedlast = m_fspeed;
                }
                DateTime dtwoliusj = DateTime.Now;
                DateTime dpinlv = DateTime.Now;
                while (true)
                {
                    Thread.Sleep(10);
                    if (m_fspeed <= fspeedend)
                    {//记录结束滑行时间
                        break;
                    }
                    if (JDhelpClass.DateDiff(DateTime.Now, dtwoliusj) >= 300)
                    {
                        float forcedq, forcejs;
                        forcedq = fForce;
                        forcejs = m_mainform.DAC.getcyz("涡流输出", fmz);
                        float fblz = 0;
                        fblz = getbljj(forcedq, forcejs);
                        //float fgonglvjs = 0;
                        izzmz += fblz;
                        float fjsd = (m_fspeedlast - m_fspeed) / 300f;
                        float fspeednext = m_fspeed - (fjsd * 300f);
                        float fforcenext = (float)fpowerex * 360f / fspeednext;//不算内阻
                        float fwoliu =  m_mainform.DAC.getwoliu("涡流输出", fforcenext);
                        fmz = fwoliu;
                        fwoliu = fwoliu + izzmz;
                        m_mainform.DAC.PutVol(fwoliu);//
                        dtwoliusj = DateTime.Now;
                        m_fspeedlast = m_fspeed;
                    }

                    string syy = DateTime.Now.ToString("yyyy");
                    string smm = DateTime.Now.ToString("MM");
                    string sdd = DateTime.Now.ToString("dd");
                    string smul = string.Format("{0}\\{1}\\{2}\\{3}", System.Windows.Forms.Application.StartupPath, syy, smm, sdd);
                    if (!Directory.Exists(smul))
                    {
                        Directory.CreateDirectory(smul);
                    }
                    string path = "";
                    path = string.Format("{0}\\{1}.ini", smul, "变加载过程数据");
                    iniclass objini = new iniclass();
                    objini.Ini(path);
                    string siniwrite = string.Format("码值：{0}，计算码值：{1}，系数码值：{2}，速度：{3}，力：{4},功率：{5}",
                      (izzmz + fmz).ToString("0"), (fmz).ToString("0"), (izzmz).ToString("0"),
                      m_fspeed.ToString("0.0"), fForce.ToString("0.0"), (m_fspeed * fForce / 360f).ToString("0.0"));
                    objini.Writue("变加载过程数据" + DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), siniwrite);
                    
                }
            }
            catch (Exception )
            { }

        }
        public void Thread2()
        {
            try
            {
                DateTime dpinlv = DateTime.Now;
                while (true)
                {
                    Thread.Sleep(20);
                    m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                    float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                    float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                    float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                    fForce = fzou + fyou + fhou;
                    if (fForce < 0)
                    {
                        fForce = 0;
                    }
                    fpower = m_fspeed * fForce / 360f;

                    if (bPutVolstart)
                    {
                        break;
                    }
                    if (JDhelpClass.DateDiff(DateTime.Now, dpinlv) > 500)
                    {
                        dSP[igcsj] = (double)m_fspeed;
                        dPW[igcsj] = fpower;
                        dFC[igcsj] = fForce;
                        dtimex[igcsj] = JDhelpClass.DateDiff(DateTime.Now, dstartgcsj) / 1000;
                        WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);


                        igcsj++;
                        dpinlv = DateTime.Now;
                    }
                }
                while (true)
                {
                    Thread.Sleep(10);
                    m_fspeed = m_mainform.DAC.getjsz("测功速度", m_mainform.DAC.fTIData[iASMSDtd]);
                    float fzou = m_mainform.DAC.getjsz("测功力左", m_mainform.DAC.fAIDataSU[iASMtdz]) - m_mainform.DAC.getjsz("测功力左",  m_mainform.DAC.fAIDataZero[iASMtdz]);
                    float fyou = m_mainform.DAC.getjsz("测功力右", m_mainform.DAC.fAIDataSU[iASMtdy]) - m_mainform.DAC.getjsz("测功力右",  m_mainform.DAC.fAIDataZero[iASMtdy]);
                    float fhou = m_mainform.DAC.getjsz("测功力后", m_mainform.DAC.fAIDataSU[iASMtdh]) - m_mainform.DAC.getjsz("测功力后",  m_mainform.DAC.fAIDataZero[iASMtdh]);

                    fForce = fzou + fyou + fhou;
                    if (fForce < 0)
                    {
                        fForce = 0;
                    }
                    fpower = m_fspeed * fForce / 360f;

                    for (int i = 0; i < listfSpeedEnd.Count; i++)
                    {
                        if (m_fspeed >= listfSpeedStart[i])
                        {
                            listdstart[i] = DateTime.Now;
                        }
                        if (m_fspeed >= listfSpeedEnd[i])
                        {
                            listdend[i] = DateTime.Now;
                        }
                    }
                    if (m_fspeed < 5)
                        break;

                    if (JDhelpClass.DateDiff(DateTime.Now, dpinlv) > 500)
                    {
                        dSP[igcsj] = (double)m_fspeed;
                        dPW[igcsj] = fpower;
                        dFC[igcsj] = fForce;
                        dtimex[igcsj] = JDhelpClass.DateDiff(DateTime.Now, dstartgcsj) / 1000;
                        WriteGraph(zedGraphControl1, dSP, dPW, igcsj + 1);


                        igcsj++;
                        dpinlv = DateTime.Now;
                    }
                }

            }
            catch
            {

            }
            MethodInvoker ln = new MethodInvoker(setjcjg);
            this.BeginInvoke(ln);
            MethodInvoker ln2 = new MethodInvoker(getlilunshijian);
            this.BeginInvoke(ln2);
            MethodInvoker ln3 = new MethodInvoker(getwucha);
            this.BeginInvoke(ln3);
        }
        public void setjcjg()
        {
            float fstartspeed1 = 0, fstartspeed2 = 0, fstartspeed3 = 0;
            float fendspeed1 = 0, fendspeed2 = 0, fendspeed3 = 0;
            float.TryParse(txtstartspeed1.Text, out fstartspeed1);
            float.TryParse(txtstartspeed2.Text, out fstartspeed2);
            float.TryParse(txtstartspeed3.Text, out fstartspeed3);
            float.TryParse(txtendspeed1.Text, out fendspeed1);
            float.TryParse(txtendspeed2.Text, out fendspeed2);
            float.TryParse(txtendspeed3.Text, out fendspeed3);

            DateTime dtstarttime1 = new DateTime();
            DateTime dtstarttime2 = new DateTime();
            DateTime dtstarttime3 = new DateTime();

            DateTime dtendtime1 = new DateTime();
            DateTime dtendtime2 = new DateTime();
            DateTime dtendtime3 = new DateTime();
            for (int i = 0; i < listfSpeedEnd.Count; i++)
            {
                if (fstartspeed1 == listfSpeedStart[i])
                {
                    dtstarttime1 = listdstart[i];
                }
                if (fstartspeed2 == listfSpeedStart[i])
                {
                    dtstarttime2 = listdstart[i];
                }
                if (fstartspeed3 == listfSpeedStart[i])
                {
                    dtstarttime3 = listdstart[i];
                }

                if (fendspeed1 == listfSpeedEnd[i])
                {
                    dtendtime1 = listdend[i];
                }
                if (fendspeed2 == listfSpeedEnd[i])
                {
                    dtendtime2 = listdend[i];
                }
                if (fendspeed3 == listfSpeedEnd[i])
                {
                    dtendtime3 = listdend[i];
                }
            }
            txtsjtime1.Text = (JDhelpClass.DateDiff(dtstarttime1, dtendtime1)/1000).ToString();
            txtsjtime2.Text = (JDhelpClass.DateDiff(dtstarttime2, dtendtime2) / 1000).ToString();
            txtsjtime3.Text = (JDhelpClass.DateDiff(dtstarttime3, dtendtime3) / 1000).ToString();
        }

        public void getlilunshijian()
        {
            float fstartspeed1 = 0, fstartspeed2 = 0, fstartspeed3 = 0;
            float fendspeed1 = 0, fendspeed2 = 0, fendspeed3 = 0;
            float.TryParse(txtstartspeed1.Text, out fstartspeed1);
            float.TryParse(txtstartspeed2.Text, out fstartspeed2);
            float.TryParse(txtstartspeed3.Text, out fstartspeed3);
            float.TryParse(txtendspeed1.Text, out fendspeed1);
            float.TryParse(txtendspeed2.Text, out fendspeed2);
            float.TryParse(txtendspeed3.Text, out fendspeed3);

            //DateTime dtstarttime1 = new DateTime();
            //DateTime dtstarttime2 = new DateTime();
            //DateTime dtstarttime3 = new DateTime();

            //DateTime dtendtime1 = new DateTime();
            //DateTime dtendtime2 = new DateTime();
            //DateTime dtendtime3 = new DateTime();
            float f1 = 0, f2 = 0, f3 = 0;
            for (int i = 0; i < listfSpeedEnd.Count; i++)
            {
                if (fstartspeed1 >= listfSpeedStart[i] && fendspeed1 <= listfSpeedEnd[i])
                {
                    f1+=(float)JDhelpClass.jdhxsj(DIW, listfSpeedStart[i], listfSpeedEnd[i], listfpower[i], 0.13);
                }
                if (fstartspeed2 >= listfSpeedStart[i] && fendspeed2 <= listfSpeedEnd[i])
                {
                    f2 += (float)JDhelpClass.jdhxsj(DIW, listfSpeedStart[i], listfSpeedEnd[i], listfpower[i], 0.13);
                }
                if (fstartspeed3 >= listfSpeedStart[i] && fendspeed3 <= listfSpeedEnd[i])
                {
                    f3 += (float)JDhelpClass.jdhxsj(DIW, listfSpeedStart[i], listfSpeedEnd[i], listfpower[i], 0.13);
                }
            }
            txtlltime1.Text = f1.ToString("0.0");// JDhelpClass.DateDiff(dtstarttime1, dtendtime1).ToString();
            txtlltime2.Text = f2.ToString("0.0");//JDhelpClass.DateDiff(dtstarttime2, dtendtime2).ToString();
            txtlltime3.Text = f3.ToString("0.0");// JDhelpClass.DateDiff(dtstarttime3, dtendtime3).ToString();
        }

        public void getwucha()
        {
            float flltime1 = 0, flltime2 = 0, flltime3 = 0;
            float fsjtime1 = 0, fsjtime2 = 0, fsjtime3 = 0;
            float.TryParse(txtlltime1.Text, out flltime1);
            float.TryParse(txtlltime2.Text, out flltime2);
            float.TryParse(txtlltime3.Text, out flltime3);

            float.TryParse(txtsjtime1.Text, out fsjtime1);
            float.TryParse(txtsjtime2.Text, out fsjtime2);
            float.TryParse(txtsjtime3.Text, out fsjtime3);
            txtwucha1.Text = (Math.Abs(flltime1 - fsjtime1) / flltime1 * 100).ToString("0.00");
            txtwucha2.Text = (Math.Abs(flltime2 - fsjtime2) / flltime2 * 100).ToString("0.00");
            txtwucha3.Text = (Math.Abs(flltime3 - fsjtime3) / flltime3 * 100).ToString("0.00");

        }
        private delegate void FlushClient();//代理
        private void xianshiSpeed()
        {
            if (this.txtsp.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiSpeed);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.txtsp.Text = string.Format(@"{0:N2}",m_fspeed);
            }
        }

        private void xianshiforce()
        {
            if (this.txtforce.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshiforce);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.txtforce.Text = string.Format(@"{0:N2}", fForce);
            }
        }

        private void xianshipower()
        {
            if (this.txtpw.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(xianshipower);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                this.txtpw.Text = string.Format(@"{0:N2}", fpower);
            }
        }
        public float getbljj(float forcedq, float forcejs)
        {
            float fbljj = 0;
            if (forcedq / forcejs > 1.04)
            {
                fbljj = -5;// 1 - forcedq / forcejs;

            }
            if (forcedq / forcejs < 0.96)
            {
                fbljj = 5;// 1 - forcedq / forcejs;

            }
            return fbljj;
        }

        public void WriteGraph(ZedGraphControl zgc, double[] izdz, double[] izdy, int icount)
        {
            xianshiSpeed();
            xianshipower();
            xianshiforce();
            double imax = 0;
            for (int i = 0; i < icount; i++)
            {
                if (imax < izdz[i])
                {
                    imax = izdz[i];
                }
            }
            imax = imax * 1.1;
            for (int i = 0; i < icount; i++)
            {

                if (imax < izdy[i])
                {
                    imax = izdy[i];
                }

            }
            imax = imax * 1.1;

            GraphPane myPane = zgc.GraphPane;
            myPane.Fill = new Fill(Color.White, Color.Aqua, 45.0f);
            myPane.Legend.Fill = new Fill(Color.Gainsboro);
            myPane.Chart.Fill = new Fill(Color.Gainsboro);

            myPane.CurveList.Clear();

            myPane.Title.Text = string.Format("曲线");

            myPane.XAxis.Title.Text = "时间(s)";
            myPane.YAxis.Title.Text = "速度(km/h)";

            myPane.YAxis.MajorGrid.IsVisible = false;
            myPane.YAxis.MinorTic.Size = 0f;

            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = imax + 0;
            myPane.YAxis.Scale.MajorStep = 0.5;

            zgc.IsShowPointValues = true;//数据节点
            string ss0 = string.Format("速度");
            string ss1 = string.Format("功率");

            PointPairList list0 = new PointPairList();
            PointPairList list1 = new PointPairList();


            LineItem myCurve0 = myPane.AddCurve(ss0, list0, Color.Blue,
                                    SymbolType.None);
            LineItem myCurve1 = myPane.AddCurve(ss1, list1, Color.Red,
                                    SymbolType.None);
            myCurve0.Line.Width = 1.7F;
            myCurve1.Line.Width = 1.7F;

            for (int i = 0; i < icount; i++)
            {
                list0.Add(i, izdz[i]);
                list1.Add(i, izdy[i]);
            }
            zgc.AxisChange();
            zgc.Invalidate();
        }

        private void but_tingzhi_Click(object sender, EventArgs e)
        {
            getlilunshijian();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            m_mainform.DAC.Lift(false);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            m_mainform.DAC.Lift(true);
        }

        
    }
}
